import { IsString, IsNotEmpty, MaxLength, IsOptional, IsEnum } from 'class-validator';
export class CreateUserDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  @IsString()
  @MaxLength(20, { message: '用户名长度不能超过20' })
  username: string;

  @IsNotEmpty({ message: '密码不能为空' })
  @IsString()
  @MaxLength(20, { message: '密码长度不能超过20' })
  password: string;

  @IsOptional()
  @IsString({ message: '昵称必须是字符串' })
  @MaxLength(20, { message: '昵称长度不能超过20个字符' })
  nickname?: string;

  @IsOptional()
  @IsString({ message: '头像必须是字符串' })
  avatar?: string;

  @IsOptional()
  @IsEnum(['admin', 'user'], { message: '角色只能是 admin 或 user' })
  role?: string;
}
